package com.jiazhong.shixi.shixixiangmu2025.bookstore.mapper;

import com.jiazhong.shixi.shixixiangmu2025.bookstore.bean.Shopping_cart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


@Mapper
public interface ShoppingCartMapper {

    @Select("select * from shopping_cart where user_id=#{user_id} and is_deleted=0")
    List<Shopping_cart> findByUserId(String user_id);

    @Insert("insert into shopping_cart values(null,#{user_id},1,#{book_id},0)")
    void add(Shopping_cart sc);

    @Update("update shopping_cart set number=number+#{number} where user_id=#{user_id} and book_id=#{book_id}")
    void update(Shopping_cart sc);
    @Update("update shopping_cart set is_deleted=1 where user_id=#{user_id} and book_id=#{book_id}")
    void remove1(Shopping_cart sc);
    @Update("update shopping_cart set is_deleted=1 where user_id=#{user_id}")
    void remove2(Shopping_cart sc);
}